<template>
  <div class="app-container">
    <el-card class="card-form">
      <div class="organization-title">专家评价明细</div>
      <el-form :model="queryForm" ref="queryForm" :inline="true">
        <el-form-item label="专家姓名" prop="expertName">
          <el-input
            v-model="queryForm.expertName"
            placeholder="请输入"
            clearable
            size="small"
            style="width: 252px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="评审类型" prop="reviewType">
          <el-select
            v-model="queryForm.reviewType"
            placeholder="请选择"
            clearable
            size="small"
            style="width: 252px"
          >
            <el-option
              v-for="dict in typeOptions"
              :key="dict.dictValue"
              :label="dict.dictLabel"
              :value="dict.dictValue"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="评分">
          <el-input
            v-model="queryForm.starScore"
            placeholder="请输入"
            clearable
            size="small"
            style="width: 120px"
            @input="
              queryForm.starScore = queryForm.starScore
                .replace(/[^\d^\.]+/g, '')
                .replace('.', '$#$')
                .replace(/\./g, '')
                .replace('$#$', '.')
            "
          />
          <span> - </span>
          <el-input
            v-model="queryForm.endScore"
            placeholder="请输入"
            clearable
            size="small"
            style="width: 120px"
            @input="
              queryForm.endScore = queryForm.endScore
                .replace(/[^\d^\.]+/g, '')
                .replace('.', '$#$')
                .replace(/\./g, '')
                .replace('$#$', '.')
            "
          />
        </el-form-item>
        <el-form-item label="评分时间">
          <el-date-picker
            v-model="dateRange"
            size="small"
            style="width: 252px"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="changeDate"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="small" @click="handleQuery"
            >查询</el-button
          >
          <el-button size="small" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card class="card-table">
      <el-row :gutter="10" class="mb20 mt5">
        <el-col :span="1.5"
          ><div style="fontsize: 14px; height: 32px; lineHeight: 32px">
            已勾选<span style="color: #3171ee; padding: 0 5px">{{
              lengthTotal
            }}</span
            >个项目
          </div>
        </el-col>
        <el-col :span="1.5">
          <el-button type="primary" size="small" @click="exportClick" v-hasPermi="['expertise:list:exportSelect']"
            >导出勾选</el-button
          >
        </el-col>
        <el-col :span="1.5">
          <el-button type="primary" size="small" @click="handleExport" v-hasPermi="['expertise:list:exportAll']"
            >导出全部</el-button
          >
        </el-col>
      </el-row>
      <el-table
        ref="multipleTable"
        v-loading="loading"
        :data="expertiseList"
        @selection-change="handleSelectionChange"
        border
      >
        <el-table-column type="selection" align="center" width="65" />
        <el-table-column label="序号" align="center" width="65" type="index" />
        <el-table-column
          label="专家姓名"
          align="center"
          prop="expertName"
          :show-overflow-tooltip="true"
          width="120"
        />
        <el-table-column
          label="评审的项目名称"
          align="center"
          prop="reviewName"
          :show-overflow-tooltip="true"
          width="220"
        />
        <el-table-column
          label="评审类型"
          align="center"
          prop="reviewType"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{
              scope.row.reviewType == 0 ? "方案评审" : "年度计划评审"
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="评分"
          align="center"
          prop="totalScore"
          width="220"
        />
        <el-table-column
          label="评分时间"
          align="center"
          prop="updateTime"
          width="220"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="handleView(scope.row)"
              >查看详情</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        v-show="total > 0"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :page-size="queryForm.pageSize"
        :current-page="queryForm.pageNum"
        :page-sizes="[10, 20, 30, 50, 100]"
      >
      </el-pagination>
    </el-card>
    <el-dialog
      title="数据概览"
      :visible.sync="showDialog"
      width="70%"
      :before-close="handleClose"
      custom-class="dialog-box"
      top="12"
    >
      <el-table
        v-loading="loading"
        :data="selectTableData"
        border
      >
        <el-table-column label="序号" align="center" width="65" type="index" />
        <el-table-column
          label="专家姓名"
          align="center"
          prop="expertName"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="评审的项目名称"
          align="center"
          prop="reviewName"
          :show-overflow-tooltip="true"
        />
        <el-table-column
          label="评审类型"
          align="center"
          prop="reviewType"
          width="180"
        >
          <template slot-scope="scope">
            <span>{{
              scope.row.reviewType == 0 ? "方案评审" : "年度计划评审"
            }}</span>
          </template>
        </el-table-column>
        <el-table-column
          label="评分"
          align="center"
          prop="totalScore"
          width="220"
        />
        <el-table-column
          label="评分时间"
          align="center"
          prop="updateTime"
          width="220"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.updateTime) }}</span>
          </template>
        </el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="submitForm">导 出</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { listExpertise ,exportExpertise } from "@/api/tripartite/expertise";
export default {
  name: "Organization",
  data() {
    return {
      // 遮罩层
      loading: true,
      showDialog: false, //弹框显示
      // 总条数
      total: 0,
      // 机构管理表格数据
      expertiseList: [],
      // 日期范围
      dateRange: [],
      // 机构类型数据字典
      typeOptions: [
        { dictValue: 0, dictLabel: "方案评审" },
        { dictValue: 1, dictLabel: "年度计划评审" },
      ],
      // 查询参数
      queryForm: {
        pageNum: 1,
        pageSize: 10,
        expertName: undefined,
        reviewType: undefined,
        starScore: undefined,
        endScore: undefined,
        starTime: undefined,
        endTime: undefined,
      },
      // 选择数据总条数
      lengthTotal: 0,
      // 弹窗表格数据
      selectTableData:[]
    };
  },
  created() {
    this.getList();
    // this.getDicts("sys_normal_disable").then((response) => {
    //   this.statusOptions = response.data;
    // });
  },
  methods: {
    /** 日期处理 */
    changeDate(val) {
      if (val) {
        this.queryForm.starTime = val[0] + " 00:00:00";
        this.queryForm.endTime = val[1] + " 23:59:59";
      }
    },
    /** 查询机构管理列表 */
    getList() {
      this.loading = true;
      listExpertise(this.addDateRange(this.queryForm)).then((response) => {
        this.expertiseList = response.list;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 选中的数据 */
    handleSelectionChange(val) {
      this.lengthTotal = val.length;
      this.multipleSelection = val;
      this.selectTableData = val;
    },
    /** 导出按钮操作 */
    exportClick() {
      console.log(999, this.selectTableData, this.selectTableData.length);
      if (this.selectTableData && this.selectTableData.length > 0) {
        this.showDialog = true;
      } else {
        this.$message.error("请先选择数据后导出");
      }
    },
    /** 关闭按钮操作 */
    handleClose() {
      this.showDialog = false;
    },
    /** 导出勾选确认 */
    submitForm() {
      return exportExpertise({
        list: this.selectTableData
      }).then(() => {
        this.showDialog = false;
      })
    },
    /** 导出全部 */
    handleExport() {
      this.$confirm(`是否导出全部,共${this.total}条数据?`, "导出", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "info"
        }).then(() => {
          return exportExpertise({
            dto: this.queryForm
          });
        })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryForm.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.queryForm.starScore = undefined;
      this.queryForm.endScore = undefined;
      this.queryForm.starTime = undefined;
      this.queryForm.endTime = undefined;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 查看按钮操作*/
    handleView(row) {
      this.$router.push({path:'/business_manage/manage/expertsdraw/detailsNoEvaluate',query:{
          type:1,
          id:row.reviewTaskId,
          way:4
        } })
    },
    /** 分页 */
    handleSizeChange(val) {
      this.queryForm.pageSize = val;
      this.getList();
    },
    handleCurrentChange(val) {
      this.queryForm.pageNum = val;
      this.getList();
    },
  },
};
</script>
<style scoped lang="scss">
.organization-title {
  font-size: 18px;
  font-family: PingFang SC, PingFang SC-Medium;
  font-weight: 500;
  margin-bottom: 24px;
  color: #000000;
}
.card-table {
  margin-top: 10px;
  .el-pagination {
    text-align: center;
    margin-top: 40px;
  }
}
</style>
<style lang="scss">
/**表单label取消加粗 */
.card-form {
  .el-card__body {
    padding-bottom: 0;
  }
  label {
    font-weight: normal !important;
  }
  .el-form--inline .el-form-item {
    margin-right: 60px;
  }
}
/* 弹出窗样式 */
.dialog-box {
  .el-dialog__body {
    padding: 24px 69px 24px 69px;
    border-top: 1px solid #ebecef;
    border-bottom: 1px solid #ebecef;
    label {
      font-weight: 400 !important;
    }
  }
  .el-dialog__footer {
    padding: 16px 20px;
  }
  .el-dialog__headerbtn {
    background: url("../../../assets/images/icon_dialog_close.png");
    background-size: 100%;
    width: 16px;
    height: 16px;
    .el-dialog__close {
      visibility: hidden;
    }
  }
}
/* el-descriptions-item 文字居中 */
.el-descriptions__body .el-descriptions__table .el-descriptions-item__cell {
  text-align: center;
}
/* 删除弹出框样式 */
.del_box {
  width: 345px;
  height: 175px;
  .el-message-box__headerbtn {
    background: url("../../../assets/images/icon_dialog_close.png");
    background-size: 100%;
    width: 16px;
    height: 16px;
    .el-message-box__close {
      visibility: hidden;
    }
  }
  .el-message-box__content {
    padding: 26px 95px;
    font-size: 16px;
    .el-message-box__status.el-icon-warning {
      color: #ea4747;
    }
    .el-message-box__status + .el-message-box__message {
      padding-right: 0;
    }
  }
}
</style>
